﻿using IdentityServer4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace IdServer
{
    public static class Config
    {
        public static IEnumerable<IdentityResource> GetIdentityResources()
        {
            return new IdentityResource[]
            {
                new IdentityResources.OpenId()
            };
        }

        public static IEnumerable<ApiResource> GetApis()
        {
            return new List<ApiResource>
            {
                new ApiResource("api1", "My API")
            };
        }

        public static IEnumerable<ApiScope> ApiScopes()
        {

            return new List<ApiScope>
            {
                   new ApiScope("api1", "My API")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = "client",
                    // 无交互用户，使用clientid/secret进行身份验证
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    //用来身份认证的 secret，防止泄露
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    // 允许访问的客户端
                    AllowedScopes = { "api1" }
                }
            };

            //然后去Startup配置  IdentityServer
        }

    }
}
